const express = require( 'express' );
const cookieParser = require( 'cookie-parser' );
const { send } = require( 'process' );

const app = express();
app.listen( 8080 );

app.use( cookieParser() );

app.get( '/set', ( req, res ) => { 
    res.cookie( 'username', 'zhangsan', { maxAge: 5 * 60 * 1000 } )
    res.send( '设置成功' );
} );

app.get( '/get', ( req, res ) => { 
    let username = req.cookies.username;
    if ( username ) {
        res.send( '你已经登录' );
    } else { 
        res.send('你没有登录')
    }
})